package com.huangsm.cloud.config;

import feign.Logger;
import feign.form.spring.SpringFormEncoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置Feign支持表单提交
 * @author huang
 * @PACKAGE_NAME com.huangsm.cloud.config
 * @PROJECT_NAME microservice-springcloud
 * @date 2019/1/16
 */
public class FeignFormSupportConfig {
    @Autowired
    private ObjectFactory<HttpMessageConverters> messageConverters;
    @Bean
    public SpringFormEncoder feignFormEncoder(){
        return new SpringFormEncoder(new SpringEncoder(messageConverters));
    }

    /**
     * 开始Feign日志
     * @return
     */
    @Bean
    public Logger.Level logger(){
        return Logger.Level.FULL;
    }
}
